import { defineStore } from 'pinia'

export const useLanguageStore = defineStore('language', {
    state: () => ({
        currentLanguage: localStorage.getItem('lang') || 'zh',
        currentAiLanguages: (localStorage.getItem('ailang') || 'zh').split(',').map(item => item),
        printType: localStorage.getItem('printType') || 'auto',
    }),
    actions: {
        setLanguage(lang) {
            this.currentLanguage = lang
            localStorage.setItem('lang', lang)
        },
        setAiLanguage(lang) {
            this.currentAiLanguages = lang
            localStorage.setItem('ailang', lang.join(','))
        },
        setPrintType(type) {
            this.printType = type
            localStorage.setItem('printType', type)
        }, 
    }
})